package com.mrjy.share.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.DistributorInfo;
import com.mrjy.share.bo.IDistributorInfoBo;
import com.mrjy.share.dto.DistributorInfoDTO;
/**
 * 推广者、分销商 controller
 * @author csshui
 *
 */
@Controller
@RequestMapping("/share/distributorInfo")
public class DistributorInfoController {
	
	@Resource
	private IDistributorInfoBo distributorInfoBo;
	

	/**
	 * 分页查询推广者列表
	 * @param 
	 * @return
	 */
	@RequestMapping("/queryDistributorInfoPage")
	@ResponseBody
	public Object queryDistributorInfoPage(DistributorInfoDTO dto ,HttpSession session){
		return distributorInfoBo.queryDistributorInfoPage(dto ,session);
	}
	/**
	 * 新增推广者 for admin
	 * @param info
	 * @return
	 */
	@RequestMapping("/add")
	@ResponseBody
	public Object add(DistributorInfo info,HttpSession session){
		return distributorInfoBo.txAdd(info,session);
	}
	
	/**
	 * 编辑推广者
	 * @param info
	 * @return
	 */
	@RequestMapping("/edit")
	@ResponseBody
	public Object edit(DistributorInfo info,HttpSession session){
		return	distributorInfoBo.txEdit(info,session);
	}
	
	/**
	 * 查询推广者
	 * @param info
	 * @return
	 */
	@RequestMapping("/queryById")
	@ResponseBody
	public Object queryById(DistributorInfo info){
		return distributorInfoBo.queryById(info);
	}
	/**
	 * 分页查询分销商列表
	 * @param 
	 * @return
	 */
	@RequestMapping("/queryPageByDistributorType")
	@ResponseBody
	public Object queryPageByDistributorType(DistributorInfoDTO dto ,HttpSession session){
		return distributorInfoBo.queryPageByDistributorType(dto ,session);
	}
	/**
	 * 更新修改邮寄状态（支持批量）
	 * @param 
	 * @return
	 */
	@RequestMapping("/updatePostalStatus")
	@ResponseBody
	public Object updatePostalStatus(DistributorInfo info,HttpSession session){
		return distributorInfoBo.txUpdatePostalStatus(info,session);
	}
	
	/**
	 * 升级推广者为分销商时更新推广者的相关信息
	 * @param info.id info.distributorName(分销商名称) info.idCard (身份证)
	 * info.bankCard (银行卡) info.fuCardNum(福卡数) info.mobilePhone(联系手机) info.address(福卡收件地址)
	 * @return
	 */
	@RequestMapping("/upgradeToDistributor")
	@ResponseBody
	public Object upgradeToDistributor(DistributorInfo info){
		return distributorInfoBo.txUpgradeToDistributor(info);
	}
	
	/**
	 * 是否是推广者
	 * @param 
	 * @return
	 */
	@RequestMapping("/isPromoterByUserId")
	@ResponseBody
	public Object isPromoterByUserId(DistributorInfo info){
		return distributorInfoBo.isPromoterByUserId(info);
	}
	
	/**
	 * @author Javin
	 * @date 2017年9月12日
	 * @desc 启用禁用分销商，支持批量, for admin
	 * @param info.ids,info.disabledFlag
	 * @return
	 */
	@RequestMapping("/updateDistributors")
	@ResponseBody
	public Object updateDistributors(DistributorInfo info,HttpSession session){
		return distributorInfoBo.txUpdateDistributors(info,session);
	}
	
	/**
	 * @author Javin
	 * @date 2017年9月12日
	 * @desc 删除分销商，支持批量, for admin
	 * @param info.ids
	 * @return
	 */
	@RequestMapping("/deleteDistributors")
	@ResponseBody
	public Object deleteDistributors(DistributorInfo info){
		return distributorInfoBo.txDeleteDistributors(info);
	}
	
	/**
	 * 导出分销商
	 * @param dto
	 * @param response
	 * @return
	 */
	@RequestMapping("/export")
	@ResponseBody
	public Object export(DistributorInfoDTO dto,HttpServletResponse response,HttpSession session){
			return distributorInfoBo.exportExl(dto,response,session);
	}
	
	/**
	 * 导出推广者
	 * @param dto
	 * @param response
	 * @return
	 */
	@RequestMapping("/export2")
	@ResponseBody
	public Object export2(DistributorInfoDTO dto,HttpServletResponse response,HttpSession session){
			return distributorInfoBo.exportExl2(dto,response,session);
	}
}
